package com.otod.pm.prj.service;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.otod.base.service.BaseService;
import com.otod.pm.prj.mapper.TaskTpMapper;
import com.otod.pm.prj.vo.TaskTpVo;


/**
 * 任务管理
 * @author jqiu
 */
@Service
@Transactional(readOnly=true)
public class TaskTpService extends BaseService {
	
	@Autowired
	TaskTpMapper taskTpMapper;
	
	/***
	 * 新增任务
	 * @param TaskTpVo
	 */
	@Transactional
	public TaskTpVo insert(TaskTpVo taskTpVo) {
		taskTpVo.setUuid(super.getUUID());
		taskTpMapper.insert(taskTpVo);
		return taskTpVo;
	}
	
	/**
	 * 修改
	 * @param map
	 */
	@Transactional
	public void update(Map<String, Object> map){
		taskTpMapper.update(map);
	}
	
	/**
	 * 删除
	 * @param id
	 */
	@Transactional
	public void deleteById(String id){
		taskTpMapper.deleteByTpId(id);
	}
	
	/**
	 * 主键查询
	 * @param id
	 */
	public TaskTpVo getById(String id){
		return taskTpMapper.getById(id);
	}
	
	/**
	 * 查询产品下所有有效果的任务
	 * @param stepId 阶段ID
	 */
	public List<TaskTpVo> queryValidList(String stepTpId){
		Map<String,Object> param = new HashMap<String, Object>();
		param.put("stepTpId",stepTpId);
		return taskTpMapper.queryForList(param);
	}
	
	/**
	 * 查询相关模板信息
	 * @param TpId 模板id
	 * @return
	 */
	public List<TaskTpVo> queryTpIdList(String stepId){
		Map<String,Object> param = new HashMap<String, Object>();
		param.put("stepTpId",stepId);
		return taskTpMapper.queryForList(param);
	}
	
}
